package com.yf1706.dao.jpa;

import java.util.Date;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.yf1706.bean.BaseSalary;
import com.yf1706.vo.BaseSalaryVO;
import com.yf1706.vo.CountBaseSalaryVO;

/**
 * 
 * @author 锦涛
 *
 */
public interface IBaseSalaryJDAO extends JpaRepository<BaseSalary, Integer>{
	
	@Query("SELECT new com.yf1706.vo.BaseSalaryVO( b.baseSalaryId,b.approveDate,b.approver,b.baseSalaryValue,"
			+ "b.mender,b.mendDate,b.remark,b.salaryBeginDate,b.salaryOffDate,"
			+ "b.emp.empName) from BaseSalary b where b.baseSalarySob.baseSalarySobId = ?1")
	Page<BaseSalaryVO> findSearch (int id, Pageable pageable);

	@Query("SELECT new com.yf1706.vo.CountBaseSalaryVO( b.emp.empId,b.baseSalaryValue) "
			+ "from BaseSalary b where b.baseSalarySob.baseSalarySobId = ?1 and "
			+ "((?2 between b.salaryBeginDate and b.salaryOffDate) or ?2 > b.salaryBeginDate)")
	List<CountBaseSalaryVO> findSearchBySidAndDate(int sId,Date countDate);
}
